package com.sooth.system.log.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.dream.system.config.Page;
import com.sooth.common.core.domain.R;
import com.sooth.common.log.annotation.Log;
import com.sooth.common.web.core.BaseController;
import com.sooth.system.log.service.ISysOperLogService;
import com.sooth.system.log.view.SysOperLogBo;
import com.sooth.system.log.view.SysOperLogDto;
import com.sooth.system.log.view.SysOperLogVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 日志信息
 *
 * @author Lion Li
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/oper-log")
public class SysOperLogController extends BaseController {

    private final ISysOperLogService operLogService;

    /**
     * 获取日志列表
     */
    @SaCheckPermission("system:oper-log:query")
    @GetMapping("/list")
    public R<Page<SysOperLogVo>> list(SysOperLogDto operLogDto, Page page) {
        return R.ok(operLogService.selectPage(operLogDto, page));
    }


    /**
     * 根据日志编号获取详细信息
     *
     * @param id 日志ID
     */
    @SaCheckPermission("system:oper-log:query")
    @GetMapping(value = "/query")
    public R<SysOperLogBo> query(@RequestParam Long id) {
        return R.ok(operLogService.selectById(id));
    }

    /**
     * 删除日志
     *
     * @param id 部门ID
     */
    @SaCheckPermission("system:oper-log:remove")
    @Log(title = "日志管理")
    @DeleteMapping("/remove")
    public R<Void> remove(@RequestParam Long id) {
        return toAjax(operLogService.deleteById(id));
    }
}
